package edu.tongji.gridding.thread;

import java.util.List;
import java.util.concurrent.CountDownLatch;

import edu.tongji.gridding.database.DocumentIndexDao;
import edu.tongji.gridding.datamodel.Result;


public class DocumentQueryThread extends Thread{
	private DocumentIndexDao dao;
	private String keyword;
	private int cnt;
	private CountDownLatch CDL;
	private List<Result> results;
	
	public DocumentQueryThread(DocumentIndexDao dao, String keyword, int cnt,
			CountDownLatch cDL, List<Result> results) {
		super();
		this.dao = dao;
		this.keyword = keyword;
		this.cnt = cnt;
		this.CDL = cDL;
		this.results = results;
	}

	@Override
	public void run() {
		Result result = new Result();
		List<String> l = dao.queryDocument(keyword, cnt);
		result.setKeyword(keyword);
		result.setReulsts(l);
		result.setCnt(l.size());
		results.add(result);
		CDL.countDown();
	}
	

}
